package com_.dxy_test_.zookeeper_.common_config_;


import java.util.Scanner;

public class ZkConfigTest {

    public static void main(String[] args) {

        ZkConfigMag mag = new ZkConfigMag();
        Config config = mag.downLoadConfigFromDB();
        System.out.println("....加载数据库配置...."+config.toString());
        mag.syncConfigToZk();
        System.out.println("....同步配置文件到zookeeper....");

        while (true) {
            String username = new Scanner(System.in).next();
            if ("exit".equals(username)) {
                break;
            } else if ("del".equals(username)) {
                mag.deleteConfig();
                System.out.println("....删除配置......");
            } else {
                //此处更新配置后同步到zookeeper，可提供后台管理
                mag.upLoadConfigToDB(username, "123456");
                System.out.println("....修改配置文件...."+config.toString());
                mag.syncConfigToZk();
                System.out.println("....同步配置文件到zookeeper....");
            }

        }



    }

}
